<include file='Index/nav'/>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 col-md-12">
            <form id='msgform' action='<{:U("Addtimemsg/addExpire")}>' method="post" style="display: none"></form>
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">
                    <h4>到期提醒短信</h4>
                </div>
                <table class="table table-hover table-bordered text-center">
                    <thead>
                        <tr>
                            <th class="text-center">距离到期天数</th>
                            <th class="text-center">短信内容</th>
                            <th class="text-center">短信签名</th>
                            <th class="text-center">发送时间</th>
                            <th class="text-center">#</th>
                        </tr>
                    </thead>
                    <tbody>
                    <foreach name="expireData" item="expire">
                        <tr>
                            <td><{$expire.nod}></td>
                            <td><{$expire.msgcontent}></td>
                            <td><{$expire.signature}></td>
                            <td><{$expire.sendtime}></td>
                            <td><a class="btn btn-danger btn-xs delexpire" href="<{:U('Addtimemsg/delExpire',array('expid'=>$expire['id']))}>">删除</a></td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
                <div class="panel-footer">
                    <{$page}>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('.msgcontent').keyup(function(){
       if($(this).val().length > 500) {
           $(this).val($(this).val().substring(0, 500));
       }
       $('#hip').text($(this).val().length);
       $('#words').text(500 - $(this).val().length);
       $('#ts').text(Math.ceil($(this).val().length / 70));
   });
   $('.delexpire').click(function(){
       var url = $(this).prop('href');
       $.get(
            url,
            function(data) {
                if (data.msg = "success") {
                    alert('删除成功');
                    window.location.reload();
                } else {
                    alert('删除失败');
                }
            }
       );
       return false;
   });
</script>